import { stringify } from 'qs';
import request from '@utils/request';

export async function query({ page = 0, size = 10 }) {
  return request(`/api/sys/resource?${stringify({ page, size })}`);
}

export async function addResource({ name, type, url, description }) {
  return request('/api/sys/resource', {
    method: 'POST',
    body: {
      name,
      type,
      url,
      description,
    },
  });
}

export async function updateResource({ id, name, type, url, description }) {
  return request(`/api/sys/resource/${id}`, {
    method: 'PUT',
    body: {
      name,
      type,
      url,
      description,
    },
  });
}
